import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Switch } from 'ant-design-vue';
import { setRoleStatus } from '@/api/demo/system';
import { useMessage } from '@/hooks/web/useMessage';

type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
  {
    title: '角色名称',
    dataIndex: 'roleName',
    width: 200,
  },
  {
    title: '角色值',
    dataIndex: 'roleValue',
    format: text => {
      let v="";
      switch (text) {
        case "manage":
          v="管理员";
          break;
        case "ms_user":
          v="普通员工";
          break;
        case "manpower":
          v="人力行政";
          break;
        default:
          v=text;
          break;
      }
      return v;
    }
  },
  {
    title: '排序',
    dataIndex: 'sort',
    width: 50,
  },
  {
    title: '类型',
    dataIndex: 'type',
    width: 80,
    format: text => {
      let v="";
      switch (text) {
        case "1":
          v="固定类型";
          break;
        case "2":
          v="部门";
          break;
        case "3":
          v="个人";
          break;
      }
      return v;
    }
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '搜索',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'type',
    label: '类型',
    component: 'Select',
    componentProps: {
      options: [
        { label: '固定类型', value: 1 },
        { label: '部门', value: 2 },
      ],
    },
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'roleName',
    label: '角色名称',
    required: true,
    component: 'Input',
  },
  {
    field: 'roleValue',
    label: '角色值',
    required: true,
    component: 'Input',
  },
  {
    field: 'sort',
    label: '排序',
    required: true,
    component: 'InputNumber',
  },
  {
    field: 'type',
    label: '类型',
    component: 'Select',
    required: true,
    componentProps: {
      options: [
        { label: '固定类型', value: 1 },
        { label: '部门', value: 2 },
        { label: '个人', value: 3 },

      ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '菜单ids',
    field: 'menu',
    slot: 'menu',
  },
];
